/**
 * 
 */
package com.etc.user.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.etc.entity.Ordercomment;
import com.etc.user.dao.OrdercommentMapper;
import com.etc.user.service.OrdercommentService;
import com.etc.util.PageData;

/**
 * @author afrian
 *
 * date: 2019年4月30日  早上10点
 */
@Repository(value = "ordercommentService")
public class OrdercommentServiceImpl implements OrdercommentService {

	@Resource(name = "ordercommentMapper")
	private OrdercommentMapper ordercommentMapper;
/**
 * 根据评论ID查询订单的评论相关信息
 */
	@Override
	public Ordercomment selectOrdercommentById(Integer commentid) {
		
		return ordercommentMapper.selectOrdercommentById(commentid);
	}
/**
 * 后端评论分页查询功能
 */
	@Override
	public PageData<Ordercomment> selectOrdercommentByPage(int page, int pageSize, String content) {

		// 之前的业务判断，此时在这里完成
		int start = (page - 1) * pageSize;

		// 查询需要返回的核心数据[指定页码的]
		List<Ordercomment> data = ordercommentMapper.selectOrdercommentByPage(start, pageSize, content);
		// 查询满足条件的记录数
		int count = ordercommentMapper.selectCount(content);
		PageData<Ordercomment> pd = new PageData<>(data, count, pageSize, page);

		return pd;
	}
/**
 * 后端系统评论管理实现更改评论状态功能
 */
	@Override
	public boolean updateOrdercomment(Ordercomment ordercomment) {
		// TODO Auto-generated method stub
		
		if(ordercomment==null) {
			return false;
		}
		return ordercommentMapper.updateOrdercomment(ordercomment)>0;
	}
/**
 * 前端个人中心添加评论和上传图片功能
 */
	public boolean updatecomment(Ordercomment ordercomment) {
		// TODO Auto-generated method stub
		
		if(ordercomment==null) {
			return false;
		}
		return ordercommentMapper.updatecomment(ordercomment)>0;
	}

	/**
	 * 前端个人中心订单列表展示
	 */
	@Override
	public PageData<Ordercomment> selectcommentByPage(int page, int pageSize, String content) {


		

		// 之前的业务判断，此时在这里完成
		int start = (page - 1) * pageSize;

		// 查询需要返回的核心数据[指定页码的]
		List<Ordercomment> data = ordercommentMapper.selectcommentByPage(start, pageSize, content);
		// 查询满足条件的记录数
		int count = ordercommentMapper.selectCount(content);
		PageData<Ordercomment> pd = new PageData<>(data, count, pageSize, page);

		return pd;
	}

	



}
